package com.ztools.mvp.proxy.impl;


import com.ztools.mvp.IPresenter;
import com.ztools.mvp.IView;
import com.ztools.mvp.proxy.MvpBindCallback;
import com.ztools.mvp.proxy.ViewLifecycleCallback;

/**
 * 管理Activity的生命周期
 * Created by zhangxuehui on 2018/3/13.
 */

public class ViewLifecycleCallbackProxy<V extends IView, P extends IPresenter<V>> implements ViewLifecycleCallback<V, P> {
    private MvpBindCallback<V, P> mTargetCallback;
    private MvpBindCallbackProxy<V, P> mTargetCallbackProxy;

    public ViewLifecycleCallbackProxy(MvpBindCallback<V, P> mTargetCallback) {
        this.mTargetCallback = mTargetCallback;
    }

    public MvpBindCallbackProxy<V, P> getMvpCallback() {
        if (mTargetCallback != null) {
            mTargetCallbackProxy = new MvpBindCallbackProxy<>(mTargetCallback);
        }
        return mTargetCallbackProxy;
    }


    @Override
    public void onAttachedToWindow() {
        getMvpCallback().newPresenter();
        getMvpCallback().newMvpView();
        getMvpCallback().attachView();
    }

    @Override
    public void onMeasure() {

    }

    @Override
    public void onSizeChanged() {

    }

    @Override
    public void onLayout() {

    }

    @Override
    public void onDraw() {

    }

    @Override
    public void onDetackedFromWindow() {
        getMvpCallback().detachView();
    }

    @Override
    public void onFinishInflate() {

    }

}
